package org.pluslibs.commons.ioplus;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class FileUtils extends  org.apache.commons.io.FileUtils{

	public static String readInputStreamToString(InputStream resourceAsStream) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(resourceAsStream));
		StringBuilder sb = new StringBuilder();
		String line = null;

		while ((line = br.readLine()) != null) {
		sb.append(line + "\n");
		}

		br.close();
		return sb.toString();
	}

	public static String readFileOnClassPathToString(String string)
			throws IOException {
		ClassLoader cl = ClassLoader.getSystemClassLoader();
		InputStream resourceAsStream = cl.getResourceAsStream(string);
		String format = readInputStreamToString(resourceAsStream);
		return format;
	}
}
